import 'package:flutter/material.dart';
import 'package:flutter_demo/core/common/utils/common_utils.dart';
import 'package:flutter_demo/core/common/utils/image_utils.dart';
import 'package:flutter_demo/core/common/values/gaps.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

/**
 * 播放数量统计
 */
class PlayCountWidget extends StatelessWidget {
  final int playCount;

  final bool needBg;

  const PlayCountWidget({required this.playCount, this.needBg = true});

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(left: 7.w, right: 7.w),
      height: 16.h,
      color: needBg ? Colors.black.withOpacity(0.2) : Colors.transparent,
      child: _playcount(),
    );
  }

  Widget _playcount() {
    return Row(
      children: [
        Image.asset(
          ImageUtils.getImagePath('icon_playcount'),
          width: 8.w,
          height: 8.w,
        ),
        Gaps.hGap1,
        Text(
          getPlayCountStrFromInt(playCount),
          style:
              TextStyle(color: Colors.white.withOpacity(0.9), fontSize: 10.sp),
        )
      ],
    );
  }
}
